import 'package:flutter/material.dart';

/*
 * @author[hansen]
 * @date[创建日期: 2022/7/8 13:55]
 * @version[版本: v1.0]
 * @function[功能简介: 展示空数据widget]
 */

class EmptyDataWidget extends StatelessWidget {
  const EmptyDataWidget({
    Key? key,
    this.iconName,
    this.iconWidth = 130,
    this.iconHeight = 130,
    this.text,
    this.emptyTextStyle,
  }) : super(key: key);

  final String? iconName;
  final double? iconWidth;
  final double? iconHeight;
  final String? text;
  final TextStyle? emptyTextStyle;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          iconName == null
              ? Icon(
                  Icons.error,
                  size: iconWidth,
                  color: emptyTextStyle?.color ?? const Color(0xFF909399),
                )
              : Image.asset(
                  iconName!,
                  width: iconWidth,
                  height: iconHeight,
                  fit: BoxFit.scaleDown,
                ),
          Text(
            text ?? "暂无数据",
            style: emptyTextStyle ??
                const TextStyle(
                  color: Color(0xFF909399),
                  fontSize: 14,
                ),
          )
        ],
      ),
    );
  }
}
